home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Applications / MacGS 2.5.2ß3 / (MacGSLib.π) / zmac.c < prev   
Encoding:
C/C++ Source or Header  |  1993-04-17  |  2.8 KB  |  145 lines  |  [TEXT/R*ch]

  1. /* Copyright (C) 1993 Aladdin Enterprises.  All rights reserved.
  2.    Distributed by Free Software Foundation, Inc.
  3.  
  4. This file is part of Ghostscript.
  5.  
  6. Ghostscript is distributed in the hope that it will be useful, but
  7. WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
  8. to anyone for the consequences of using it or for whether it serves any
  9. particular purpose or works at all, unless he says so in writing.  Refer
  10. to the Ghostscript General Public License for full details.
  11.  
  12. Everyone is granted permission to copy, modify and redistribute
  13. Ghostscript, but only under the conditions described in the Ghostscript
  14. General Public License.  A copy of this license is supposed to have been
  15. given to you along with Ghostscript so you can know your rights and
  16. responsibilities.  It should be in a file named COPYING.  Among other
  17. things, the copyright notice and this notice must be preserved on all
  18. copies.  */
  19.  
  20.  
  21. /* zmac.c */
  22. /* Macintosh operators for Ghostscript */
  23. #include "ghost.h"
  24. #include "errors.h"
  25. #include "oper.h"
  26. #include "stream.h"
  27. #include "estack.h"
  28. #include "store.h"
  29. #include "files.h"
  30. #include "gsmatrix.h"            /* for gxdevice.h */
  31. #include "gxdevice.h"
  32. #include "gxdevmem.h"
  33.  
  34.  
  35. #define MAC_GS_VERSION        2523
  36.  
  37.  
  38. /* .macconfirm         -  ->  true    (Resume)    */
  39. /*                        or false (Abort)    */
  40.  
  41.     private int
  42. zMacConfirm (register os_ptr op)
  43.  
  44. {
  45.     Boolean            fWasResume;
  46.     extern    Boolean    doMacConfirm (void);
  47.  
  48.  
  49.     fWasResume = doMacConfirm ();
  50.  
  51.     push (1);
  52.     make_bool (op, fWasResume ? 1 : 0);
  53.  
  54.     return 0;
  55. }
  56.  
  57.  
  58. /* .macopenfile         -  ->  file true    */
  59. /*                            or false        */
  60.  
  61.     private int
  62. zMacOpenFile (register os_ptr op)
  63.  
  64. {
  65.     ref                runFile;
  66.     Boolean            fHaveFile;
  67.     extern    short    doMacOpenFile (ref *pRunFile);
  68.  
  69.  
  70.     if (fHaveFile = (doMacOpenFile (&runFile) == 0))
  71.     {
  72.         push (1);
  73.         *op = runFile;
  74.         SetCursor (*GetCursor (watchCursor));
  75.     }
  76.  
  77.     push (1);
  78.     make_bool (op, fHaveFile ? 1 : 0);
  79.  
  80.     return 0;
  81. }
  82.  
  83.  
  84. /* .macGSversion         -  ->  version    */
  85.  
  86.     private int
  87. zMacGSversion (register os_ptr op)
  88.  
  89. {
  90.     push (1);
  91.     make_int (op, MAC_GS_VERSION);
  92.  
  93.     return 0;
  94. }
  95.  
  96.  
  97. /*    .macAlert            string  ->    true    (alert displayed)    */
  98. /*                    or    int        ->    boolean                        */
  99.  
  100.     private int
  101. zMacAlert (register os_ptr op)
  102.  
  103. {
  104.     Boolean    fSuccess = FALSE;
  105.     Boolean gp_mac_alert (char *msg, short lenStr, short index);
  106.  
  107.  
  108.     switch (r_type (op))
  109.     {
  110.         default:
  111.             return e_typecheck;
  112.  
  113.         case t_integer:
  114.             if (op->value.intval < 1)
  115.                 return e_undefinedresult;
  116.             else
  117.                 fSuccess = gp_mac_alert ((char *) NULL, 0, op->value.intval);
  118.  
  119.             break;
  120.  
  121.         case t_string:
  122.             fSuccess = gp_mac_alert ((char *) op->value.bytes, r_size (op), 0);
  123.             
  124.             break;
  125.     }
  126.  
  127.     make_bool (op, fSuccess ? 1 : 0);
  128.  
  129.     return 0;
  130. }
  131.  
  132.  
  133. /* ------ Initialization procedure ------ */
  134.  
  135. op_def zmac_op_defs[] =
  136. {
  137.     {"0.macconfirm"  , zMacConfirm},
  138.     {"0.macopenfile" , zMacOpenFile},
  139.     {"0.macGSversion", zMacGSversion},
  140.     {"1.macalert"     , zMacAlert},
  141.     op_def_end (0)
  142. };
  143.  
  144.  
  145.